Mateusz BaryĆa, Konrad Lewszyk
May 26, 2022
What we looked for in our target study:
1. Available data with labeled and coherent variables
2. Available survey process
3. Available codes
4. A realistic reproducible approach
Link to our survey: https://docs.google.com/forms/d/e/1FAIpQLSeN__k2KDdbRZIkhZ3ubUIVTXc6kPAtjSIqh1bI07bDzVrpNg/viewform?fbclid=IwAR26g8tf0azKeNHSU1FgNR1wvvhTrOis891X9dU9bBNVU1gdfoan9cZkcVE
We extended the study by collecting data from Polish respondents and we managed to get a little over 20 respondents to participate. As the sample we collected was rather small, there was no point in extending the study by Polandâs regional analysis. Therefore we focued on the radar graphs and the perceptions of risk by country.
It is crucial to mention that the study was conducted during the onset of the pandemic in 2020. Our extension of the study was done after the vaccination period and towards the end of the pandemic. This means that our respondents could perceive risk differently now than they have two years ago. Simply put the time factor impacts our study.
| INTNR | gender | age | MUN_ITA | NUTS2 | V9_1 | V9_2 | V9_3 | V9_4 | V9_5 | V9_6 | V9_7 | V9_8 | V9_9 | V19_1 | V19_2 | V19_3 | V19_4 | V19_5 | V19_6 | V19_7 | V19_8 | V19_9 | V29_1 | V29_2 | V29_3 | V29_4 | V29_5 | V29_6 | V29_7 | V29_8 | V29_9 | V49_1 | V49_2 | V49_3 | V49_4 | V49_5 | V49_6 | V49_7 | V49_8 | V49_9 | V39_1 | V39_2 | V39_3 | V39_4 | V39_5 | V39_6 | V39_7 | V39_8 | V39_9 | V69_1 | V69_2 | V69_3 | V69_4 | V69_5 | V69_6 | V69_7 | V69_8 | V69_9 | V59_1 | V59_2 | V59_3 | V59_4 | V59_5 | V59_6 | V59_7 | V59_8 | V59_9 | V79_1 | V79_2 | V79_3 | V79_4 | V79_5 | V79_6 | V79_7 | V79_8 | V79_9 | V90 | V100 | V110 | V120 | V130 | vikt | kvotgrupp2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---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| 2 | 2 | 2 | 4 | 5 | 1 | 1 | 2 | 0.736 | 1 |
| Sygnatura.czasowa | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠEpidemics. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠFloods. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠDroughts. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠWildfires. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠEarthquakes. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠTerror.attacks. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠDomestic.violence. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠEconomic.crises. | X1..How.likely.do.you.think.it.is.that.you.are.directly.involved.in.the.following.phenomenaâŠClimate.change. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠEpidemics. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠFloods. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠDroughts. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠWildfires. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠEarthquakes. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠTerror.attacks. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠDomestic.violence. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠEconomic.crises. | X2..In.case.you.are.directly.involved..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.youâŠClimate.change. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠEpidemics. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠFloods. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠDroughts. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠWildfires. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠEarthquakes. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠTerror.attacks. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠDomestic.violence. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠEconomic.crises. | X3..In.case.they.occur.in.Poland..how.much.damage.do.you.think.the.following.phenomena.can.cause.to.others.living.in.PolandâŠClimate.change. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠEpidemics. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠFloods. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠDroughts. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠWildfires. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠEarthquakes. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠTerror.attacks. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠDomestic.violence. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠEconomic.crises. | X4..How.prepared.do.you.think.the.responsible.authorities.in.Poland.are.to.face.the.following.phenomenaâŠClimate.change. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠEpidemics. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠFloods. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠDroughts. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠWildfires. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠEarthquakes. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠTerror.attacks. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠDomestic.violence. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠEconomic.crises. | X5..In.case.you.are.directly.involved..how.prepared.do.you.think.you.are.to.face.the.following.phenomenaâŠClimate.change. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠEpidemics. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠFloods. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠDroughts. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠWildfires. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠEarthquakes. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠTerror.attacks. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠDomestic.violence. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠEconomic.crises. | X6..How.knowledgeable.are.the.responsible.authorities.in.Poland.on.the.following.phenomenaâŠClimate.change. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠEpidemics. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠFloods. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠDroughts. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠWildfires. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠEarthquakes. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠTerror.attacks. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠDomestic.violence. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠEconomic.crises. | X7..How.knowledgeable.are.you.on.the.following.phenomenaâŠClimate.change. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠEpidemics. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠFloods. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠDroughts. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠWildfires. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠEarthquakes. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠTerror.attacks. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠDomestic.violence. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠEconomic.crises. | X8..Have.you.ever.been.directly.involved.in.the.following.phenomena..in.Poland.or.abroadâŠClimate.change. | X9..What.is.the.highest.level.of.education.you.achieved. | X10..To.satisfy.your.family.needs..your.household.income.is. | X11..Do.you.have.a.job. | X12..Which.of.the.following.categories.best.represent.the.sector.in.which.you.are.employed. | What.is.your.gender. | What.is.your.age. |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2022/05/14 6:33:48 PM EET | 5 Very likely | 5 Very likely | 4 | 4 | 4 | 4 | 5 Very likely | 5 Very likely | 5 Very likely | 5. Severe damage | 5. Severe damage | 4 | 3 | 2 | 3 | 4 | 5. Severe damage | 4 | 5. Severe damage | 5. Severe damage | 4 | 5. Severe damage | 4 | 4 | 5. Severe damage | 4 | 4 | 5. Highly prepared | 5. Highly prepared | 4 | 3 | 3 | 2 | 2 | 2 | 3 | 5. Highly prepared | 4 | 5. Highly prepared | 3 | 3 | 4 | 4 | 3 | 2 | 3 | 4 | 3 | 4 | 3 | 2 | 4 | 3 | 3 | 5. Highly knowledgeable | 4 | 3 | 4 | 5. Highly knowledgeable | 5. Highly knowledgeable | 4 | 5. Highly knowledgeable | 4 | yes | yes | no | no | yes | yes | yes | yes | no | University degree or higher | 4 | Yes | IT & telecommunications | Male | 18 |
| 2022/05/18 4:13:26 PM EET | 5 Very likely | 3 | 2 | 1. Not likely at all | 1. Not likely at all | 5 Very likely | 3 | 5 Very likely | 4 | 5. Severe damage | 3 | 3 | 2 | 1. No damage | 5. Severe damage | 5. Severe damage | 5. Severe damage | 5. Severe damage | 4 | 4 | 3 | 4 | 4 | 2 | 2 | 5. Severe damage | 5. Severe damage | 4 | 2 | 1. Not at all prepared | 1. Not at all prepared | 1. Not at all prepared | 5. Highly prepared | 5. Highly prepared | 4 | 3 | 5. Highly prepared | 3 | 3 | 3 | 3 | 1. Not at all prepared | 3 | 4 | 3 | 5. Highly knowledgeable | 4 | 2 | 1. Not at all knowledgeable | 2 | 4 | 4 | 3 | 5. Highly knowledgeable | 5. Highly knowledgeable | 3 | 3 | 2 | 2 | 2 | 2 | 5. Highly knowledgeable | 3 | yes | yes | no | no | no | yes | no | yes | no | University degree or higher | 4 | Yes | IT & telecommunications | Male | 25 |
| 2022/05/18 5:37:35 PM EET | 4 | 1. Not likely at all | 3 | 1. Not likely at all | 1. Not likely at all | 1. Not likely at all | 1. Not likely at all | 1. Not likely at all | 2 | 3 | I donât know | 2 | I donât know | I donât know | I donât know | I donât know | I donât know | 3 | 3 | 3 | 2 | 1. No damage | 1. No damage | 2 | 3 | 4 | 3 | 3 | 2 | 2 | 1. Not at all prepared | 1. Not at all prepared | 1. Not at all prepared | 1. Not at all prepared | 1. Not at all prepared | 2 | 3 | I donât know | 2 | I donât know | I donât know | I donât know | I donât know | 3 | 2 | 3 | 2 | 2 | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 2 | 2 | 2 | 3 | 2 | 2 | 2 | 2 | 2 | 2 | 4 | 4 | Yes | No | Yes | Yes | Yes | No | No | Yes | Yes | University degree or higher | 5 | No | IT & telecommunications | Male | 26 |
| 2022/05/20 1:34:34 PM EET | 4 | 1. Not likely at all | 2 | 1. Not likely at all | 1. Not likely at all | 2 | 3 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 2 | 2 | 2 | 2 | 2 | 2 | 1. Not at all prepared | 1. Not at all prepared | 1. Not at all prepared | 4 | 2 | 2 | 2 | 2 | 1. Not at all prepared | 3 | 3 | 2 | 1. Not at all knowledgeable | 2 | 2 | 2 | 2 | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | Yes | No | No | No | No | No | No | Yes | Yes | University degree or higher | 4 | Yes | Bank, finance and insurance | Female | 26 |
| 2022/05/20 1:50:32 PM EET | 5 Very likely | 3 | 3 | 2 | 1. Not likely at all | 3 | 3 | 3 | 4 | 4 | 3 | 3 | 2 | 1. No damage | 4 | 4 | 4 | 4 | 5. Severe damage | 4 | 4 | 3 | 1. No damage | 5. Severe damage | 5. Severe damage | 5. Severe damage | 5. Severe damage | 2 | 4 | 2 | 4 | 1. Not at all prepared | 4 | 3 | 2 | 2 | 4 | 4 | 4 | 4 | 4 | 3 | 3 | 3 | 2 | 2 | 4 | 4 | 3 | 1. Not at all knowledgeable | 4 | 4 | 2 | 2 | 3 | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 1. Not at all knowledgeable | 3 | 4 | 3 | 3 | Yes | No | No | No | Yes | No | Yes | Yes | Yes | University degree or higher | 5 | Yes | IT & telecommunications | Male | 26 |
| 2022/05/20 2:44:31 PM EET | 5 Very likely | 2 | 3 | 2 | 1. Not likely at all | 2 | 2 | 4 | 4 | 3 | 4 | 3 | 4 | 5. Severe damage | 3 | 5. Severe damage | 4 | 3 | 4 | 4 | 3 | 3 | 2 | 3 | 4 | 4 | 3 | 3 | 3 | 3 | 3 | 2 | 2 | 3 | 2 | 2 | 4 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 2 | 3 | 3 | 3 | 2 | 2 | 3 | 3 | 2 | 2 | 3 | 2 | 2 | 2 | 2 | 3 | 3 | 4 | 2 | Yes | No | No | No | No | Yes | No | Yes | Yes | University degree or higher | 4 | No | Other category | Male | 24 |
Defining functions for data preparation and graphing
#' Returns tibble with only necessary columns for aggregation.
#'
#' @param dataframe_to_derive_column_names A tibble based on which the necessary columns will be derived.
#' @param dataframe_to_modify A tibble that will be used for subsetting.
#' @param start index of the first column
#' @param end index of the last column
#' @return tibble only with columns between start and end indexes and an area column
derive_necessary_columns <- function(dataframe_to_derive_column_names, dataframe_to_modify, start, end){
only_columns_for_chart <- dataframe_to_derive_column_names[,c(start:end, 85)] %>% names()
final_dataframe <- dataframe_to_modify %>% select(all_of(only_columns_for_chart))
return(final_dataframe)
}#' Returns tibble aggregated by the chosen variable.
#'
#' @param dataset A tibble based on which the necessary columns will be derived.
#' @param start index of the first column
#' @param end index of the last column
#' @param aggregating_variable the grouping column
#' @return aggregated tibble
aggregate_method <- function(dataset, start, end, aggregating_variable){
return(aggregate(dataset[,start:end], by = list(aggregating_variable),
FUN = mean, na.rm = TRUE))
}#' Returns complete dataframe for a country, with the structure that is required by
#' by radarchart function from fmsb library.
#'
#' @param dataframe_1 First dataframe
#' @param dataframe_2 index of the first column
#' @param row_to_select index of the row to select from the final DataFrame
#' @param rowname_1 name of the first rowname
#' @param rowname_2 name of the second rowname
#' @return dataframe for the country
derive_dataframe_for_country <- function(dataframe_1, dataframe_2, row_to_select,
rowname_1, rowname_2){
colnames(dataframe_1) <- c("area", "Epidemics", "Floods", "Drought", "Wildfires", "Earthquakes",
"Terror attacks", "Domestic violence", "Economic crises", "Climate Change")
colnames(dataframe_2) <- c("area", "Epidemics", "Floods", "Drought", "Wildfires", "Earthquakes",
"Terror attacks", "Domestic violence", "Economic crises", "Climate Change")
df_to_return <- rbind(dataframe_1[row_to_select,], dataframe_2[row_to_select,])
df_to_return <- df_to_return[,2:10]
rownames(df_to_return) <- c(rowname_1, rowname_2)
df_to_return <- rbind(rep(5,9) , rep(1,9) , df_to_return) #needed for creating radarchart successfully
return(df_to_return)
}#' Plots the radarchart based on the provided DataFrame, with the given title,
#' The labels in the legend correspond to legend_1 and legend_2.
#'
#' @param dataframe dataframe that is required by radarchart function from fmsb library.
#' @param title title to put on the chart
#' @param legend_1 legend for the first froup
#' @param legend_2 legend for the second group
#' @return dataframe for the country
graph_radar <- function(dataframe, title, legend_1, legend_2){
graph <- radarchart(dataframe,
axistype = 1 ,
#customize the polygons
pcol = colors_border,
#pfcol = , # for filling the polygons
pty = 32,
plwd = 2,
plty = 1,
#customize the grid
cglcol = "grey",
cglty = 1,
axislabcol = "grey",
caxislabels = seq(1,5,1),
cglwd = 0.8,
#custom labels
vlcex = 0.9,
title = title)
legend(x = 1.5, y = 1, legend = c(legend_1, legend_2),
bty = "n", pch = 20 , col = colors_border, text.width = 2, cex = 0.8, pt.cex = 2)
}